<%--
  Created by IntelliJ IDEA.
  User: cjt
  Date: 2020/12/10
  Time: 18:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>用户管理</title>
    <link rel="stylesheet" href="/css/main.css">
    <link rel="stylesheet" href="/css/font-awesome/css/font-awesome.css">
</head>
<body>
<div class="box">
    <h3>用户信息管理</h3>
    <div class="actions">
        <div>
            <a class="btn btn-primary" href="/user/toAdd">添加用户信息</a>
        </div>
    </div>

    <table class="list">
        <tr>
            <th>序号</th>
            <th>登录号码</th>
            <th>真实姓名</th>
            <th>性别</th>
            <th>账号状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${users.list}" var="user">
            <tr>
                <td>${user.user_id}</td>
                <td>${user.username}</td>
                <td>${user.realname}</td>
                <td>${user.sex == "1" ? "女" : "男"}</td>
                <td>${user.state == "0" ? "启用" : "禁用"}</td>
                <td><fmt:formatDate value="${user.create_time}" pattern="yyyy-MM-dd"/></td>
                <td>
                    <a class="fa fa-info" title="详情" href="/user/detail?id=${user.user_id}"></a>
                    &nbsp;&nbsp;
                    <a class="fa fa-pencil" title="编辑" href="/user/toEdit?id=${user.user_id}"></a>
                    &nbsp;&nbsp;
                    <a class="fa fa-remove" title="删除" href="/user/del?id=${user.user_id}" onclick="confirmDelete(1)"></a>
                </td>
            </tr>
        </c:forEach>

    </table>
    <div class="pager-info">
        <div>共有 ${users.total} 条记录，第 ${users.pageNum }/${users.pages} 页 </div>
        <div>
            <ul class="pagination">
                <li class="paginate_button previous disabled }">
                    <c:if test="${users.hasPreviousPage}">
                        <a href="/user/list?currentPage=${users.prePage}">上一页</a>
                    </c:if>
                </li>
                <li class="paginate_button active"><a href="#">${users.pageNum}</a></li>
                <li class="paginate_button next disabled">
                    <c:if test="${users.hasNextPage}">
                        <a href="/user/list?currentPage=${users.nextPage}">下一页</a>
                    </c:if>
                </li>
            </ul>
        </div>
    </div>
</div>
<script src="/js/jQuery.js"></script>
<script>
    function confirmDelete(id){
        if (confirm("确定要删除码？")) {
            alert('发送删除请求，刷新页面（不要异步）');
        }
        return false;
    }
</script>
</body>
</html>
